<template>
  <button @click="changeName">姓名：{{ name }}</button>
  <button @click="changeCout">计算属性：{{ count }}</button>
</template>

<script setup>
import { ref, watch } from "vue";
const name = ref("莉莉");
const changeName = () => {
  name.value = "李莉莉";
};
const count = ref(0);
const changeCout = () => {
  count.value++;
};
// watch 监听多个数据源
watch(
  [name, count],
  ([newName, oldName], [newCount, oldCount]) => {
    console.log("count或者name变化l", [newCount, oldCount], [newName, oldName]);
  },
  {
    immediate: true, // 立即执行
  }
);
</script>

<style>
#app {
  width: 100vw;
  height: 100vh;
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
</style>
